﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="wanted.aspx.cs" Inherits="hunter" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div id="view">
        <h2 style=" vertical-align:middle;">發布通緝令</h2>
       
        <table style=" margin:10px 0 auto; padding:0px; border: 1px solid; left:0px;">
            <tr>
                <td><asp:Label ID="Label14" runat="server" Text="通緝令發起人"></asp:Label></td>
                <td><asp:TextBox ID="MNameTextBox" runat="server" ReadOnly="True" Enabled="False"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label15" runat="server" Text="通緝令發布日期"></asp:Label></td>
                <td> <asp:TextBox ID="WStartTextBox" runat="server" ReadOnly="True" Enabled="False"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label17" runat="server" Text="通緝令結束日期"></asp:Label></td>
                <td> <asp:TextBox ID="WEndTextBox" runat="server" ReadOnly="True" Enabled="False"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label1" runat="server" Text="商品名稱"></asp:Label></td>
                <td><asp:TextBox ID="WGNameTextBox" runat="server"></asp:TextBox></td>
                <td colspan='2'><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="WGNameTextBox" ErrorMessage="* 商品名稱不得為空"></asp:RequiredFieldValidator></td>
            </tr>

            <tr>
                <td> <asp:Label ID="Label2" runat="server" Text="商品種類 (實體/虛擬)"></asp:Label>
</td>
                <td><asp:DropDownList ID="GCFirstDropDownList" runat="server" AutoPostBack="True" 
            DataSourceID="GCFirstSqlDataSource" DataTextField="GCfirst" 
            DataValueField="GCfirst">
        </asp:DropDownList></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label5" runat="server" Text="商品種類 (次分類)"></asp:Label></td>
                <td><asp:DropDownList ID="GCSecondDropDownList" runat="server" AutoPostBack="True" 
            DataSourceID="GCSecondSqlDataSource" DataTextField="GCsecond" 
            DataValueField="GCsecond">
        </asp:DropDownList></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label6" runat="server" Text="商品種類 (細項分類)"></asp:Label></td>
                <td><asp:DropDownList ID="GCThirdDropDownList" runat="server" DataSourceID="GCThirdSqlDataSource" DataTextField="GCthird" 
            DataValueField="GCId">
        </asp:DropDownList></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label7" runat="server" Text="商品數量"></asp:Label></td>
                <td><asp:TextBox ID="WGAmountTextBox" runat="server"></asp:TextBox></td>
                <td><asp:RangeValidator ID="WGAmountRangeValidator" runat="server" 
            ControlToValidate="WGAmountTextBox" ErrorMessage="* 數量必須大於 0" 
            MaximumValue="65535" MinimumValue="1" SetFocusOnError="True" Type="Integer"></asp:RangeValidator></td>
                <td>
                    <asp:RequiredFieldValidator ID="WGAmountRequiredFieldValidator" runat="server" ErrorMessage="* 數量不得為空" 
                    ControlToValidate="WGAmountTextBox"></asp:RequiredFieldValidator>
                </td>
            </tr>

            <tr>
                <td><asp:Label ID="Label13" runat="server" Text="預算"></asp:Label></td>
                <td><asp:TextBox ID="WGBudgetTextBox" runat="server"></asp:TextBox></td>
                <td><asp:RangeValidator ID="WGBudgetRangeValidator" runat="server" ControlToValidate="WGBudgetTextBox" ErrorMessage="* 金額必須大於 0" MinimumValue="1" Type="Integer"></asp:RangeValidator></td>
                <td><asp:RequiredFieldValidator ID="WGBudgetRequiredFieldValidator" runat="server" ControlToValidate="WGBudgetTextBox" ErrorMessage="* 金額不得為空"></asp:RequiredFieldValidator></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label3" runat="server" Text="商品年份"></asp:Label></td>
                <td><asp:TextBox ID="WGYearTextBox" runat="server"></asp:TextBox></td>
                <td colspan="2"><asp:RangeValidator ID="WGYearTextBoxRangeValidator" runat="server" ControlToValidate="WGYearTextBox" ErrorMessage="* 西元的年份必須介於1~今年" MinimumValue="1" Type="Integer"></asp:RangeValidator></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label8" runat="server" Text="月份"></asp:Label></td>
                <td><asp:DropDownList ID="WGMonthTextBoxDropDownList" runat="server">
                        <asp:ListItem Value="1">1月</asp:ListItem>
                        <asp:ListItem Value="2">2月</asp:ListItem>
                        <asp:ListItem Value="3">3月</asp:ListItem>
                        <asp:ListItem Value="4">4月</asp:ListItem>
                        <asp:ListItem Value="5">5月</asp:ListItem>
                        <asp:ListItem Value="6">6月</asp:ListItem>
                        <asp:ListItem Value="7">7月</asp:ListItem>
                        <asp:ListItem Value="8">8月</asp:ListItem>
                        <asp:ListItem Value="9">9月</asp:ListItem>
                        <asp:ListItem Value="10">10月</asp:ListItem>
                        <asp:ListItem Value="11">11月</asp:ListItem>
                        <asp:ListItem Value="12">12月</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>

            <tr>
                <td><asp:Label ID="Label4" runat="server" Text="商品國籍/產地"></asp:Label></td>
                <td><asp:TextBox ID="WGMadeInTextBox" runat="server">台灣</asp:TextBox></td>
                <td colspan="2"><asp:RequiredFieldValidator ID="WGMadeInRequiredFieldValidator" runat="server" 
            ControlToValidate="WGMadeInTextBox" ErrorMessage="* 必須輸入產地"></asp:RequiredFieldValidator></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label9" runat="server" Text="商品品牌 (選填)"></asp:Label></td>
                <td><asp:TextBox ID="WGBrandTextBox" runat="server"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label10" runat="server" Text="商品圖片"></asp:Label></td>
                <td><asp:FileUpload ID="PictureFileUpload" runat="server" /></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label11" runat="server" Text="特殊用途 (選填)"></asp:Label></td>
                <td><asp:TextBox ID="WGAppTextBox" runat="server"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label12" runat="server" Text="商品外觀描述(選填)"></asp:Label></td>
                <td><asp:TextBox ID="WGDescriptionTextBox" runat="server"></asp:TextBox></td>
            </tr>

            <tr>
                <td><asp:Label ID="Label16" runat="server" Text="指定的交易方式"></asp:Label></td>
                <td><asp:ListBox ID="WTranListBox" runat="server" SelectionMode="Multiple" 
                    ToolTip="(按 Ctrl 鍵 可以複選交易的方式)">
                    <asp:ListItem>面交</asp:ListItem>
                    <asp:ListItem>超商取貨</asp:ListItem>
                    <asp:ListItem>宅配</asp:ListItem>
                    </asp:ListBox>
                </td>
                <td colspan='2'> <asp:RequiredFieldValidator ID="WTranListBoxRequiredFieldValidator" 
            runat="server" ControlToValidate="WTranListBox" ErrorMessage="* 必須指定交易方式"></asp:RequiredFieldValidator></td>
            </tr>

            <tr>
                <td><asp:Button ID="SubmitButton" runat="server" Text="發布通緝令" onclick="SubmitButton_Click" style="height: 21px" /></td>
            </tr>

        </table>

        <asp:GridView ID="WantedGridView" runat="server" Visible="False"></asp:GridView>
        <asp:ListView ID="GoodsPicListView" runat="server"></asp:ListView>
        <br />

        <asp:SqlDataSource ID="GCPic" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            SelectCommand="SELECT * FROM [GoodsPic]" 
            DeleteCommand="DELETE FROM [GoodsPic] WHERE [GPId] = @GPId" 
            InsertCommand="INSERT INTO [GoodsPic] ([GPServName], [GPName], [GPNote]) VALUES (@GPServName, @GPName, @GPNote)" 
            
            UpdateCommand="UPDATE [GoodsPic] SET [GPServName] = @GPServName, [GPName] = @GPName, [GPNote] = @GPNote WHERE [GPId] = @GPId">
            <DeleteParameters>
                <asp:Parameter Name="GPId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="GPServName" Type="String" />
                <asp:Parameter Name="GPName" Type="String" />
                <asp:Parameter Name="GPNote" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="GPServName" Type="String" />
                <asp:Parameter Name="GPName" Type="String" />
                <asp:Parameter Name="GPNote" Type="String" />
                <asp:Parameter Name="GPId" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="MyWantedSqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            InsertCommand="INSERT INTO Wanted(WId, WStart, WEnd, MId, HCId, WTran, WVisible, GCId, WGPId, WGApp, WGAmount, WGName, WGDescription, WGYear, WGBrand, WGMadeIn, WGBudget, WNote) VALUES (@WId, @WStart, @WEnd, @MId, @HCId, @WTran, @WVisible, @GCId, @WGPId, @WGApp, @WGAmount, @WGName, @WGDescription, @WGYear, @WGBrand, @WGMadeIn, @WGBudget, @WNote)" 
            SelectCommand="SELECT WId, WStart, WEnd, MId, HCId, WTran, WVisible, GCId, WGPId, WGApp, WGAmount, WGName, WGDescription, WGYear, WGBrand, WGMadeIn, WGBudget, WNote FROM Wanted WHERE (WId = @WId)">
            <InsertParameters>
                
                <asp:Parameter Name="WId" Type="Int32" />
                <asp:Parameter Name="WStart" />
                <asp:Parameter Name="WEnd" />
                <asp:Parameter Name="MId" Type="Int32" />
                <asp:Parameter Name="HCId" Type="Int32" />
                <asp:Parameter Name="WTran" Type="String" />
                <asp:Parameter Name="WVisible" Type="Boolean" DefaultValue="true" />
                <asp:Parameter Name="GCId" Type="Int32" />
                <asp:Parameter Name="WGPId" Type="Int32" />
                <asp:Parameter Name="WGApp" Type="String" />
                <asp:Parameter Name="WGAmount" Type="Int32" DefaultValue="1" />
                <asp:Parameter Name="WGName" Type="String" />
                <asp:Parameter Name="WGDescription" Type="String" />
                <asp:Parameter Name="WGYear" />
                <asp:Parameter Name="WGBrand" Type="String" DefaultValue="" />
                <asp:Parameter Name="WGMadeIn" Type="String" />
                <asp:Parameter Name="WGBudget" Type="Int32" />
                <asp:Parameter Name="WNote" Type="String" DefaultValue="" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="MNameTextBox" Name="MName" PropertyName="Text" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <br />
        <asp:SqlDataSource ID="GCFirstSqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            
            SelectCommand="SELECT DISTINCT GCfirst FROM GoodsCategory ORDER BY GCfirst">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="GCSecondSqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            
            SelectCommand="SELECT DISTINCT GCsecond FROM GoodsCategory WHERE (GCfirst = @GCfirst)">
            <SelectParameters>
                <asp:ControlParameter ControlID="GCFirstDropDownList" Name="GCfirst" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="GCThirdSqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
            
            SelectCommand="SELECT DISTINCT GCId, GCthird FROM GoodsCategory WHERE (GCsecond = @GCsecond)">
            <SelectParameters>
                <asp:ControlParameter ControlID="GCSecondDropDownList" Name="GCsecond" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>

